//
//  QYDataModel.swift
//  QingYuJSQ
//
//  Created by 李东 on 2024/4/5.
//

import UIKit
import HandyJSON

class QYDataModel: HandyJSON {
    required init() {
        
    }
    var emotion = ""
    var ts = 0
    var content = ""
    var fileName = ""
    var ids = 0
    var time = ""
    var yearAndMonth = ""
    var week = "" 
    var date = "" //02.09
    var height = 0
    
    var getHeight: Int {
        if height > 0 {
            return height
        }
        height = Int(countCellHeight()) + 1
        return height
    }
    
    //计算cell高度存起来，列表展示使用
    func countCellHeight() -> CGFloat{
        var cellHeight: CGFloat = 195
        if !time.isEmpty {//时间部分的高度
            cellHeight += 32
        }
        if !content.isEmpty {
            cellHeight += 15
            let contentHeight = content.getHeight(font: UIFont.systemFont(ofSize: 16), width: CGFloat.screenWidth - 80)
            cellHeight += contentHeight
        }
        cellHeight += 45
        if !fileName.isEmpty {
            cellHeight += (CGFloat.screenWidth-80+20)
        }
        return cellHeight
    }
    
 
}
